dpp.SendTo DPNID_ALL_PLAYERS_GROUP, oBuf, 0, DPNSEND_GUARANTEED Or DPNSEND_NOLOOPBACK
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdClient_Click()
'Show the settings screen, and re-adjust them
frmVoiceSettings.Show vbModal
dvClient.SetClientConfig oClient
End Sub
Private Sub Form_Load()
Dim dpGroupInfo As DPN_GROUP_INFO
Dim lCount As Long
DPlayEventsForm.RegisterCallback Me
'First let's set up the DirectPlayVoice stuff since that's the point of this demo
If DPlayEventsForm.IsHost Then
'After we've created (and opened) the session and got the first player, let's start
'the DplayVoice server
If (dvServer Is Nothing) Then Set dvServer = dx.DirectPlayVoiceServerCreate
dvServer.Initialize dpp, 0
dvServer.StartSession oSession, 0
End If
'Now create a client as well (so we can both talk and listen)
Set dvClient = dx.DirectPlayVoiceClientCreate
'Now let's create a client event..
dvClient.StartClientNotification Me
dvClient.Initialize dpp, 0
oSound.hwndAppWindow = Me.hwnd
On Error Resume Next
dvClient.Connect oSound, oClient, 0
If Err.Number = DVERR_RUN_SETUP Then 'The audio tests have not been run on this
'machine. Run them now.
'we need to run setup first
Dim dvSetup As DirectPlayVoiceTest8
Set dvSetup = dx.DirectPlayVoiceTestCreate
dvSetup.CheckAudioSetup vbNullString, vbNullString, Me.hwnd, 0 'Check the default devices since that's what we'll be using
If Err.Number = DVERR_COMMANDALREADYPENDING Then
MsgBox "Could not start DirectPlayVoice. The Voice Networking wizard is already open. This sample must exit.", vbOKOnly Or vbInformation, "No Voice"
Cleanup
Unload Me
End
End If
If Err.Number = DVERR_USERCANCEL Then
MsgBox "Could not start DirectPlayVoice. The Voice Networking wizard has been cancelled. This sample must exit.", vbOKOnly Or vbInformation, "No Voice"
Cleanup
Unload Me
End
End If
Set dvSetup = Nothing
dvClient.Connect oSound, oClient, 0
ElseIf Err.Number <> 0 And Err.Number <> DVERR_PENDING Then
MsgBox "Could not start DirectPlayVoice. This sample must exit." & vbCrLf & "Error:" & CStr(Err.Number), vbOKOnly Or vbCritical, "Exiting"
Cleanup
Unload Me
End
End If
'We need to create our 5 groups
For lCount = 1 To 5
With dpGroupInfo
.lInfoFlags = DPNINFO_NAME
.Name = "Group" & CStr(lCount)
End With
dpp.CreateGroup dpGroupInfo, 0
Next
cboMyGroup.ListIndex = 0
cboTalkingGroup.ListIndex = 0
UpdatePlayerList
End Sub
Public Sub AddPlayer(ByVal lPlayerID As Long, ByVal sName As String)
Dim lItem As ListItem
Set lItem = lvMembers.ListItems.Add(, "K" & CStr(lPlayerID), sName)
lItem.SubItems(1) = "Silent"
lItem.SubItems(2) = cboMyGroup.List(0)
lItem.SubItems(3) = cboTalkingGroup.List(0)
End Sub
Public Sub RemovePlayer(ByVal lPlayerID As Long)
Dim lCount As Long
For lCount = lvMembers.ListItems.Count To 1 Step -1
If lvMembers.ListItems.Item(lCount).Key = "K" & CStr(lPlayerID) Then
'Remove this one
lvMembers.ListItems.Remove lCount
End If
Next
End Sub
Private Sub Form_Unload(Cancel As Integer)
Me.Hide
DPlayEventsForm.DoSleep 50
Cleanup
End Sub
Public Sub UpdateTarget(ByVal lPlayerID As Long, ByVal lIndex As Long)
Dim lCount As Long
For lCount = lvMembers.ListItems.Count To 1 Step -1
If lvMembers.ListItems.Item(lCount).Key = "K" & CStr(lPlayerID) Then